package com.itheima.impl;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.CheckItemDao;
import com.itheima.service.CheckItemService;
import entity.PageResult;
import entity.QueryPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import pojo.CheckItem;

import java.util.List;

/**
 * 检查项服务
 */

@Service(interfaceClass = CheckItemService.class)
/*@Transactional*/
public class CheckItemServiceImpl implements CheckItemService {
    
    @Autowired
    private CheckItemDao checkItemDao;
    
    @Override
    public void add(CheckItem checkItem) {
        checkItemDao.add(checkItem);
    }
    
    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
        //当前页
        Integer currentPage = queryPageBean.getCurrentPage();
        //页长
        Integer pageSize = queryPageBean.getPageSize();
        //查询条件
        String queryString = queryPageBean.getQueryString();
        PageHelper.startPage(currentPage,pageSize);
        Page<CheckItem> checkItems = checkItemDao.selectByCondition(queryString);
        return new PageResult(checkItems.getTotal(),checkItems.getResult());
    }
    
    @Override
    public void edit(CheckItem checkItem) {
        checkItemDao.edit(checkItem);
    }
    
    @Override
    public void deleteById(Integer id) {
        checkItemDao.deleteById(id);
        
    }
    
    @Override
    public List<CheckItem> findAll() {
        return checkItemDao.findAll();
    }
    
}
